home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12982 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: colossus.holonet.net!russell
  2. From: russell@news.mdli.com (Russell Blackadar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: What is wrong with this code?
  5. Date: 18 Mar 1996 19:57:58 GMT
  6. Organization: HoloNet National Internet Access System: 510-704-1058/modem
  7. Message-ID: <4ikf86$8tr@colossus.holonet.net>
  8. References: <4il0pn$fp@news1.io.org>
  9. NNTP-Posting-Host: jubal.mdli.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Ivan (ticica@io.org) wrote:
  13.  
  14. >   Please, can someone tell me what's wrong with this program? It's driving 
  15. > me nuts.  When I compile it with Borland C++ 3.1 I get null pointer 
  16. > assignment. With Watcom C++ 9.5 the last line (cout << a * 3) prints some 
  17. > junk. Thanks in advance.
  18.  
  19. [Code deleted]
  20.  
  21. I believe your main problem (there may be others) is that you have no
  22. copy constructor.  In your operator*, the vecret object is destroyed
  23. at exit, and its data deleted; but the returned vector (by virtue of
  24. the compiler-generated copy ctor) contains a copy of the data pointer
  25. that still references the deleted data.
  26. --
  27. Russell Blackadar,   russell@mdli.com
  28.